define([], function() {
	return function(content, loading) {
		var token = localStorage.getItem("token");
		loading.hide();

		var form = content.find("form");

		loading = weui.loading("获取数据中");

		$.post(
			"user/get.do", {
				"token": token
			},
			function(data) {
				loading.hide();
				if(data.ok) {
					if(data.user != null) {
						$.each(data.user, function(name, value) {
							form.find("[name='" + name + "']").val(value);
						});
					}
				} else {
					weui.topTips(data.message);
				}
			}, "json"
		);

		form.submit(function(e) {
			if(form[0].pwd2.value != form[0].pwd3.value) {
				weui.topTips("两次输入的新密码不一致");
				return false;
			}

			loading = weui.loading("数据提交中");
			var ps = form.serializeArray();
			ps.push({
				name: "token",
				value: token
			});
			$.post(
				"user/pwd.do",
				ps,
				function(data) {
					loading.hide();
					if(data.ok) {
						weui.toast('修改成功', {
							duration: 1000,
							callback: function() {
								history.back();
							}
						});
					} else {
						weui.topTips(data.message);
					}
				}, "json"
			);

			return false;
		});

		content.find("._back").click(function() {
			history.back();
		});

	}
});